package lab.gene.service.impl;

import java.util.Date;
import java.util.List;

import lab.gene.dao.GeneDAO;
import lab.gene.pojo.Gene;
import lab.gene.pojo.GeneAmpliconPurification;
import lab.gene.dao.GeneAmpliconPurificationDAO;
import lab.gene.service.GeneAmpliconPurificationService;
import lab.user.dao.UserDAO;
import lab.user.pojo.User;

public class GeneAmpliconPurificationServiceImpl implements
		GeneAmpliconPurificationService {

	@Override
	public void addGeneAMP(String geneName, String userName, String stepType,
			String ampType, Float ml, Date recordDate, String comments) {
		// TODO Auto-generated method stub
		UserDAO udao = new UserDAO();
		GeneDAO gdao = new GeneDAO();
		Gene g = gdao.getGene(geneName);
		User u = udao.getUser(userName);
		
		GeneAmpliconPurification amp = new GeneAmpliconPurification();
		amp.setAmpType(ampType);
		amp.setComments(comments);
		amp.setDateModified(new Date());
		amp.setGene(g);
		amp.setMl(ml);
		amp.setRecordDate(recordDate);
		amp.setStepType(stepType);
		amp.setUser(u);
		
		GeneAmpliconPurificationDAO dao = new GeneAmpliconPurificationDAO();
		dao.addGeneAmplification(amp);
	}

	@Override
	public GeneAmpliconPurification getGeneAmpliconPurification(
			String geneName, String stepType, String ampType) {
		// TODO Auto-generated method stub
		GeneAmpliconPurification amp = null;
		GeneAmpliconPurificationDAO dao = new GeneAmpliconPurificationDAO();
		GeneDAO gdao = new GeneDAO();
		Gene g = gdao.getGene(geneName);
		amp = dao.getGeneAmpliconPurification(g, stepType, ampType);
		return amp;
	}

	@Override
	public List<GeneAmpliconPurification> getGeneAmpliconPurificationHistory(
			String geneName, String stepType, String ampType) {
		// TODO Auto-generated method stub
		List<GeneAmpliconPurification> g = null;
		GeneAmpliconPurificationDAO dao = new GeneAmpliconPurificationDAO();
		GeneDAO gdao = new GeneDAO();
		Gene gene = gdao.getGene(geneName);
		g = dao.getGeneAmpliconPurificationHistory(gene, stepType, ampType);
		return g;
	}

}
